package com.xhcl.web.controller.system;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xhcl.common.annotation.Log;
import com.xhcl.common.enums.BusinessType;
import com.xhcl.system.domain.AccountReport;
import com.xhcl.system.domain.SubstanceDebt;
import com.xhcl.system.domain.TGgHsdw;
import com.xhcl.system.domain.TGgKmdm;
import com.xhcl.system.domain.TSrhsAccountTemp;
import com.xhcl.system.domain.TSrhsHsxtcs;
import com.xhcl.system.domain.TSrhsKmye;
import com.xhcl.system.domain.TSrhsZcfz;
import com.xhcl.system.domain.TSrhsZybb;
import com.xhcl.system.model.SubstanceDebtAll;
import com.xhcl.system.service.ITGgHsdwService;
import com.xhcl.system.service.ITSrhsAccountTempService;
import com.xhcl.system.service.ITSrhsHsxtcsService;
import com.xhcl.system.service.ITSrhsKmyeService;
import com.xhcl.system.service.ITSrhsZcfzService;
import com.xhcl.system.service.ITSrhsZybbService;
import com.xhcl.common.core.controller.BaseController;
import com.xhcl.common.core.domain.AjaxResult;
import com.xhcl.common.utils.StringUtils;
import com.xhcl.framework.uitls.poi.ExcelUtil;
import com.xhcl.framework.shiro.util.ShiroUtils;
import com.xhcl.common.core.page.TableDataInfo;

/**
 * 资产负债表Controller
 * 
 * @author xhcl
 * @date 2020-09-03
 */
@Controller
@RequestMapping("/system/zcfzb")
public class TSrhsZcfzbController extends BaseController
{
    private String prefix = "system/zcfzb";

    @Autowired
    private ITSrhsAccountTempService tSrhsAccountTempService;
    @Autowired
    private ITSrhsHsxtcsService tSrhsHsxtcsService;
 
    
    @Autowired
    private ITSrhsZcfzService tSrhsZcfzService;

    @RequiresPermissions("system:zcfzb:view")
    @GetMapping()
    public String zcfzb(ModelMap mmap)
    {
    	String year=tSrhsHsxtcsService.getHsxtcsnr("year");
    	String term=tSrhsHsxtcsService.getHsxtcsnr("term");
    	List<String> ndlist=new ArrayList();
    	for (int i=0;i<5;i++) {
    		ndlist.add(String.valueOf(Integer.parseInt(year)-i));
    	}
    	mmap.put("ndlist", ndlist);
    	mmap.put("year", year);
    	List<String> yflist=new ArrayList();
    	for (int i=1;i<=12;i++) {
    		yflist.add(String.valueOf(i));
    	}
    	mmap.put("yflist", yflist);
    	mmap.put("term", term);
        return prefix + "/zcfzb";
    }
    
    /**
     * 查询资产负债表列表
     */
    @RequiresPermissions("system:zcfzb:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TSrhsZcfz tSrhsZcfz)
    {
    	List<SubstanceDebtAll> list = tSrhsZcfzService.selectTSrhsZcfzReportList(tSrhsZcfz);
        return getDataTable(list);
    }

    /**
     * 导出资产负债表
     */
    @RequiresPermissions("system:zcfzb:export")
    @Log(title = "资产负债表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TSrhsZcfz tSrhsZcfz)
    {
    	List<SubstanceDebtAll> list = tSrhsZcfzService.selectTSrhsZcfzReportList(tSrhsZcfz);
        ExcelUtil<SubstanceDebtAll> util = new ExcelUtil<SubstanceDebtAll>(SubstanceDebtAll.class);
        return util.exportExcel(list, "zcfzb");
    }
    
     
}
